<<<<<<< HEAD
<template>
  <div class="repair-form">
    <el-row>
      <el-col :span="24">
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item>
            <el-input placeholder="请输入工程名称" v-model="formSearch.name" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-select v-model="formSearch.status" placeholder="请选择状态" clearable>
              <el-option label="待接单" value="待接单"></el-option>
              <el-option label="进行中" value="进行中"></el-option>
              <el-option label="已完成" value="已完成"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="toSearch">搜索</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>

    <div class="table">
      <el-table :data="workData" style="width: 100%">
        <el-table-column type="index" label="序号" width="60px" align="center">
        </el-table-column>
        <el-table-column type="expand">
          <template>
            <el-form label-position="left" inline class="demo-table-expand"></el-form>
          </template>
        </el-table-column>
        <el-table-column prop="engineer_name" label="工程名称" width="400px" align="center">
        </el-table-column>
        <el-table-column prop="device_name" label="设备名称" width="300px" align="center">
        </el-table-column>
        <el-table-column prop="bill_why" label="问题描述" width="200px" align="center">
        </el-table-column>
        <el-table-column prop="status" label="状态" align="center">
          <template v-slot="scope">
            <el-tag v-if="scope.row.status == '进行中'" type="success">{{ scope.row.status }}</el-tag>
            <el-tag v-else-if="scope.row.status == '已完成'" type="warning">{{ scope.row.status }}</el-tag>
            <el-tag v-else type="danger">{{ scope.row.status }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="type" label="工单类型" align="center">
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template v-slot="scope">
            <el-link type="primary" :underline="false" @click="toJump(scope.row)"> 详情 </el-link>
            <el-link :disabled =" scope.row.status=='待接单' ? false : true" type="danger" @click="toDelete(scope.row.id)"
              :underline="false" style="margin-left:10px">取消</el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="params.page"
        :page-sizes="[5, 10, 15, 20]" :page-size="params.pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { get, del } from '@/utils/request'
export default {
  data() {
    return {
      //搜索表单
      formSearch: {
        name: '',
        status: ''
      },
      //表格数据源
      workData: [],
      total: 0,
      params: {
        page: 1,
        pageSize: 5
      },
    };
  },
  methods: {
    toJump(row) {
      // 路由跳转 
      this.$router.push({
        path: '/details1',
        query: row
      })
    },
    // 去删除 
    toDelete(id) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        // 点击了确定按钮 发送删除请求 
        let res = await del('/workorder/deleteById', { id: id });
        // 删除完从第一页载入数据
        this.params.page = 1;
        // 重新载入数据
        this.getWorkData();
        this.$message({
          type: 'success',
          message: res.message
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 每页条数变化
    handleSizeChange(val) {
      this.params.pageSize = val;
      this.getWorkData();
    },
    // 当前页变化
    handleCurrentChange(val) {
      this.params.page = val;
      this.getWorkData();
    },
    //去查询
    toSearch() {
      this.params.page = 1;
      this.getWorkData();
    },
    async getWorkData() {
      let temp = {
        ...this.params,
        ...this.formSearch
      }
      let res = await get('/workorder/pageQuery', temp);
      this.workData = res.data.list;
      this.total = res.data.total || 0;
    },
  },
  created() {
    this.getWorkData();
  },
};
</script>
<style lang="scss" scoped>
.repair-form {
  padding: 10px;
}

.el-link {
  font-size: 12px;
}
</style>
=======
>>>>>>> 6ae8c38e86a7e359e2e1774f25f2668c22f7f0ec
